import Cookies from 'js-cookie'
import md5 from 'js-md5';

const TokenKey = 'Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token,{ expires: 7 })
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getHeader(){
  let timestamp=Date.parse(new Date())/1000;
  return {
    "Authorization": "Bearer " + getToken(),
    "timestamp":timestamp,//计算时间戳
    "sign":md5("SC."+timestamp+".SC").toUpperCase()
  };
}

